import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/job',
    component: () => import('../views/job.vue'),
    children: [
      {
        path: 'find',
        component: () => import('../views/second/find.vue'),
        children: [
          {
            path: 'zonghe',
            component: () => import('../views/third/zonghe.vue'),
          },
          {
            path: "",
            redirect: "zonghe"
          }
        ]
      },
      {
        path: 'shixi',
        component: () => import('../views/second/shixi.vue'),
        children: [
          {
            path: 'zong',
            component: () => import('../views/third/zong.vue')
          },
          {
            path: 'web',
            component: () => import('../views/third/web.vue')
          },
          {
            path: "",
            redirect: "zong"
          }
        ]
      },
      {
        path: 'jianjob',
        component: () => import('../views/second/jianjob.vue'),
        children: [
          {
            path: 'zonghe2',
            component: () => import('../views/third/zonghe2.vue'),
          },
          {
            path: "",
            redirect: "zonghe2"
          }
        ]
      },
      {
        path: 'alljob',
        component: () => import('../views/second/alljob.vue'),
        children: [
          {
            path: 'zong2',
            component: () => import('../views/third/zong2.vue')
          },
          {
            path: 'web2',
            component: () => import('../views/third/web2.vue')
          },
          {
            path: "",
            redirect: "zong2"
          }
        ]
      },
      {
        path: "",
        redirect: "find"
      }
    ]
  },
  {
    path: '/have',
    component: () => import('../views/have.vue'),
  },
  {
    path: '/search',
    component: () => import('../views/second/search.vue'),
  },
  {
    path: '/baike',
    component: () => import('../views/second/baike.vue'),
  },
  {
    path: '/zhibo',
    component: () => import('../views/second/zhibo.vue'),
  },
  {
    path: '/shenfen',
    component: () => import('../views/second/shenfen.vue'),
  },
  {
    path: '/msg',
    component: () => import('../views/msg.vue'),
    children: [
      {
        path: 'liaotian',
        component: () => import('../views/second/liaotian.vue'),
        children: [
          {
            path: 'all',
            component: () => import('../views/third/all.vue')
          },
          {
            path: 'zhaohu',
            component: () => import('../views/third/zhaohu.vue')
          },
          {
            path: 'goutong',
            component: () => import('../views/third/goutong.vue')
          },
          {
            path: "",
            redirect: "all"
          }
        ]
      },
      {
        path: 'hudong',
        component: () => import('../views/second/hudong.vue'),
        children: [
          {
            path: 'xingqu',
            component: () => import('../views/third/xingqu.vue')
          },
          {
            path: 'saw',
            component: () => import('../views/third/saw.vue')
          },
          {
            path: 'newjob',
            component: () => import('../views/third/newjob.vue')
          },
          {
            path: "",
            redirect: "xingqu"
          }
        ]
      },
      {
        path: "",
        redirect: "liaotian"
      }
    ]
  },
  {
    path: '/mine',
    component: () => import('../views/mine.vue'),
    beforeEnter(to,from,next){
      if(confirm('登录过后才能进入？')) {
        next()
      } else {
        next(false)
      }
    }
  },
  {
    path: '/login',
    component: () => import('../views/login.vue')
  },
  {
    path: '/regist',
    component: () => import('../views/regist.vue')
  },
  {
    path: '/study',
    component: () => import('../views/study/study.vue'),
  },
  {
    path: '/zia',
    component: () => import('../views/study/zia.vue'),
  },
  {
    path: '/common',
    component: () => import('../views/study/common.vue')
  },
  {
    path: '/zi',
    component: () => import('../views/study/zi.vue')
  },
  {
    path: '/fu',
    component: () => import('../views/study/fu.vue')
  },
  {
    path: '/detail',
    component: () => import('../views/detail/detail.vue')
  },
  {
    path: '/',
    redirect: '/login'
  },
  {
    path: '*',
    name: 'no',
    component: () => import('@/components/no.vue')
  }
]

const router = new VueRouter({
  // mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
